package ioc;

import material.Material;
import commands.Command;

public class CheckableButtonImpl implements Checkable {

	private int ID;
	private Command command;
	private boolean previousState;

	public CheckableButtonImpl(int ID) {
		this.ID = ID;
	}
	
	public void setCommand(Command command) {
		this.command = command;
	}
	
	public void check() {
		boolean newState = Material.MaterielInstance().getClavier().touchePressee(ID);
		if(newState != previousState) {
			command.execute();
		}
		previousState = newState;
	}
	
}
